var movie = angular.module('movie', ['ngAnimate']);

movie.controller('movieCtrl', ['$scope', '$http', function($scope, $http) {
	$scope.movies = [];
	$http.get('/movie.json')
	.success(function(data, status, headers, config) {
		$scope.movies =  movies = data;
	}).error(function(data, status, headers, config) {
		alert("发生错误啦，请联系管理员QQ:348928400");
	});

	var movies;

	$scope.selectByTag = function(tag) {
		var moviesTemp = [];
		movies.forEach(function(movie) {
			for(var i=0; i<movie.tags.length; i++) {
				if(movie.tags[i] == tag) {
					moviesTemp.push(movie);
					break;
				}
			}
		});
		$scope.movies = [];
		$scope.movies = moviesTemp;
	};
}]);